//
//  SDPhotoDetailInfoCell.m
//  SKinDiary
//
//  Created by pcyang on 16/7/17.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import "SDPhotoDetailInfoCell.h"


@interface SDPhotoDetailInfoCell()
@property(nonatomic,strong)UIView* bottomLineView;
@end


@implementation SDPhotoDetailInfoCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 13)];
        _titleLabel.font = [UIFont systemFontOfSize:13];
        _titleLabel.textColor = [UIColor colorWithRGB:0xb4bec8];
        _titleLabel.textAlignment = NSTextAlignmentRight;
        _titleLabel.text = @"";
        [self.contentView addSubview:_titleLabel];
        
        _subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 13)];
        _subTitleLabel.font = [UIFont systemFontOfSize:13];
        _subTitleLabel.textColor = [UIColor colorWithRGB:0x747f8b];
        [self.contentView addSubview:_subTitleLabel];
    
        _arrowLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 13)];
        _arrowLabel.font = [UIFont systemFontOfSize:13];
        _arrowLabel.textColor = [UIColor colorWithRGB:0x747f8b];
        _arrowLabel.text = @">";
        [self.contentView addSubview:_arrowLabel];
        
//       _bottomLineView = [[UIView alloc] initWithFrame:CGRectMake(kTagLeftPadding, kPhotoDetailInfoCellHeight - 1, kScreenWidth - 2*kTagLeftPadding, 1)];
//        [_bottomLineView setBackgroundColor:[UIColor colorWithRGB:0xcad6e3]];
//        [self.contentView addSubview:_bottomLineView];

    }
    return self;
}

-(void)setCellData:(NSString*)title subtitle:(NSString*)subtitle
{
    _arrowLabel.hidden = YES;
    _titleLabel.text = title;
    _subTitleLabel.text = subtitle;
    [_titleLabel sizeToFit];
    [_subTitleLabel sizeToFit];
    [_arrowLabel sizeToFit];
    [self setNeedsLayout];
}

-(void)layoutSubviews
{
    _arrowLabel.right = kScreenWidth - 40;
    _titleLabel.right = 65;
    _titleLabel.top = (self.height - _titleLabel.height)/2;
    _subTitleLabel.left = _titleLabel.right + 20;
    _subTitleLabel.top = _titleLabel.top;
    _arrowLabel.top = (self.height - _arrowLabel.height)/2;
    _subTitleLabel.width = kScreenWidth - _subTitleLabel.left - 60;
}

+(float)getRequiredCellHeight:(NSString*)commentStr
{
    __block float height = 0.0f;
    
    if (CHECK_VALID_STRING(commentStr)) {
        CGSize size = [commentStr sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(kScreenWidth - 145,MAXFLOAT)];
        height = size.height + 2* kTagLeftPadding;
        return height;
    }
    
    return kPhotoDetailInfoCellHeight;
}
@end
